{% extends 'wsite.html' %}

{% block page_name %} seed list  {% endblock %}

{% block page_content %}
    <div class="page-header">
        <h2 class="pager-title">seed List</h2>
    </div>
    <div class="wsite-pager">
        <div class="form-inline">
            <div class="form-group">

            </div>
            <div class="form-group">
                <button class="btn btn-primary" onclick="javascript: history.back(-1);">返回</button>
            </div>
        </div>
        <h2></h2>
        <div class="table-responsive">
            <table class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>seed name</th>
                        <th>hot</th>
                        <th>formatter size</th>
                        <th>submit time</th>
                        <th>search channel</th>
                        <th>created time</th>
                        <th>updated time</th>
                        <th>operate</th>
                    </tr>
                </thead>
                <tbody>
                    {% for s in seed_page.items %}
                        <tr>
                            <td>{{ loop.index }}</td>
                            <td>{{ s.name }}</td>
                            <td>{{ s.hot }}</td>
                            <td>{{ s.size }}</td>
                            <td>{{ moment(s.made_time).fromNow(refresh=True) }}</td>
                            <td>{{ s.search_channel }}</td>
                            <td>{{ s.created_time }}</td>
                            <td>{{ s.updated_time }}</td>
                            <td>
                                <a href="javascript:void(0);" onclick="copy_uri('{{ s.uri }}')">
                                    <span class="glyphicon glyphicon-magnet"></span>
                                </a>
                                &nbsp;
                                <a href="#">
                                    <span class="glyphicon glyphicon-option-horizontal"></span>
                                </a>
                            </td>
                        </tr>
                    {% endfor %}

                </tbody>
            </table>
        </div>
    </div>
{% endblock %}

{% block scripts %}
    {{ super() }}
    <script type="text/javascript">
        function copy_uri(copyedUri) {
            console.log('uri', copyedUri);

            var save = function (e) {
                console.log('e', e);
                e.clipboardData.setData('text/plain', copyedUri);
                e.preventDefault()
            };
            document.addEventListener('copy', save);
            document.execCommand('copy');
            document.removeEventListener('copy', save);
            alert('copy success');
        }
    </script>
{% endblock %}

